package com.jueban.Vo;

import com.jueban.model.Announcement;
import com.jueban.model.user.User;
import lombok.Data;
import org.springframework.data.domain.Page;

import java.util.ArrayList;
import java.util.List;

@Data
public class AnnouncementsVo extends ResultVo
{

    List<AnnouncementVo> announcementVos = new ArrayList<AnnouncementVo>();
    int offset;
    int pageNumber;
    int pageSize;

    /*
    public UsersVo(Page<User> userPage) {
        setProperties(userPage);
    }*/

    public AnnouncementsVo() {

    }

    public void setProperties(Page<Announcement> announcementPage) {
        pageSize = announcementPage.getSize();
        pageNumber = announcementPage.getTotalPages();
        offset = announcementPage.getNumber();
        for (Announcement announcement: announcementPage) {
            AnnouncementVo announcementVo = new AnnouncementVo(announcement);
            announcementVos.add(announcementVo);
        }
    }

}
